package com.ysy.java.plugin;


import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

public class MyClassVistor extends ClassVisitor {

    String superName;

    public MyClassVistor( ClassVisitor cv) {
        super(Opcodes.ASM4, cv);
    }

    @Override
    public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
        super.visit(version, access, name, signature, superName, interfaces);
        this.superName=superName;
    }

    @Override
    public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
//        return super.visitMethod(access, name, desc, signature, exceptions);
        MethodVisitor methodVisitor = cv.visitMethod(access, name, desc, signature, exceptions);
        if (superName.equals("android/app/Activity") && name.equals("onCreate")){
            System.out.println( "visitMethod: "+superName );
            MyClassVisitorMethod myClassVisitorMethod = new MyClassVisitorMethod(methodVisitor);
            return myClassVisitorMethod;
        }
        return methodVisitor;
    }
}
